import React, { Component } from 'react'
import PropTypes from 'prop-types'

export class Test extends Component {
  constructor(props) {
    super(props)
    this.state = {
      data: [{ name: 1 }, { name: 2 }],
    }
  }
  render() {
    return (
      <>
        <hr />
        <TestSon data={this.state.data}></TestSon>
      </>
    )
  }
}
export class TestSon extends Component {
  render() {
    return (
      <>
        <span>
          <div>class组件父组件穿过来的props：</div>
          {this.props.data.map(item => {
            return <div key={item.name}>{item.name}</div>
          })}
        </span>
      </>
    )
  }
}
TestSon.propTypes = {
  data: PropTypes.array.isRequired,
}
